<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%
	String contextPath = request.getContextPath();
%>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="pragma" content="no-cache">  
<meta http-equiv="cache-control" content="no-cache">  
<meta http-equiv="expires" content="0"> 

<link rel="stylesheet" type="text/css" href="<%=contextPath %>/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="<%=contextPath %>/themes/icon.css">
<script type="text/javascript" src="<%=contextPath %>/js/jquery-1.7.1.js"></script>
<script type="text/javascript" src="<%=contextPath %>/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=contextPath %>/js/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="<%=contextPath %>/js/base.js"></script>
<script>contextPath = "<%=contextPath %>";</script>

<script language="javascript">
$(function() {
		
	initDatePicker("query_startPendTime");
	initDatePicker("query_endPendTime");
	initDatePicker("query_startPstartTime");
	initDatePicker("query_endPstartTime");

	initButton("query-project", function() {
		$("#queryForm").attr("action", "project_listAction.action");
		$("#queryForm").submit();
	});
	
	initButton("query-reset", function() {
		$("#query_projectName").val("");
		$("#query_projectCode").val("");
		$("#query_subsidiaryId").val("");
		$("#query_subsidiaryName").val("");
		
		$("#query_startPendTime").datebox('setValue', '');
		$("#query_endPendTime").datebox('setValue', '');
		$("#query_startPstartTime").datebox('setValue', '');
		$("#query_endPstartTime").datebox('setValue', '');
	
	});
	
	initButton("delete-project", function() {
		$("#queryForm").attr("action", "project_deleteProjectAction.action");
		deleteRecord('queryForm', 'dataTable', 'projectId');
	});
	
	initButton("create-project", function() {
		openAddForm();
	});
	
	initButton("modify-project", function() {
		openModifyForm();
	});
	
	
	$('#dataTable').datagrid(
			{
				url: "project_dataGridAction.action?"+buildCondition(),
				width: '100%',
				height: 'auto',
				striped: true,
				fitColumns: false,
				pagination:true,
				columns:[[
					{field:'projectId',checkbox:true},
					{field:'projectCode',title:'项目编号',width:80},
					{field:'projectName',title:'项目名称',width:120},
					{field:'subsidiaryName',title:'所属公司',width:80},
					{field:'budgetAmount',title:'预算金额',width:80,
						formatter:function(value){
							return moneyForamt(value);	
						}},
					{field:'content',title:'项目内容',width:120},
					{field:'employeeName',title:'项目经理',width:80},
					{field:'startTime',title:'立项日期',width:100,
						formatter:function(value,rec){
							if (value == null || value == '') {
								return '';
							} else {
								return new Date(Date.parse(value.replace(/-/g, "/"))).format("yyyy-MM-dd");	
							}							
						}},
					{field:'endTime',title:'结项日期',width:100,
						formatter:function(value,rec){
							if (value == null || value == '') {
								return '';
							} else {
								return new Date(Date.parse(value.replace(/-/g, "/"))).format("yyyy-MM-dd");	
							}							
						}},
					{field:'createTime',title:'建立时间',width:140},
					{field:'updateTime',title:'更新时间',width:140},
					{field:'remark',title:'备注'}
				]]
			});
});


function buildCondition() {
	
	return "query_projectName="+
		encodeURIComponent($("#query_projectName").val())+
			"&query_projectCode="+
		$("#query_projectCode").val()+
			"&query_subsidiaryId="+
		$("#query_subsidiaryId").val()+
			"&query_startPendTime="+
		$("#query_startPendTime").datebox('getValue')+
			"&query_endPendTime="+
		$("#query_endPendTime").datebox('getValue')+
			"&query_startPstartTime="+
		$("#query_startPstartTime").datebox('getValue')+
			"&query_endPstartTime="+
		$("#query_endPstartTime").datebox('getValue');
}
   
</script>
</head>

<body>

<form id="queryForm" action="project_listAction.action" method="post">

<div id="queryDiv" class="easyui-accordion" border="false" style="width: 400px;">
	<div title="查询" iconCls="icon-search" style="overflow:auto;padding:10px;">
	<table>
		<tr>
			<td>
				<label style="float: left; margin-right: 5px;">项目名称:</label>
				<s:textfield name="query_projectName" theme="simple"  />
			</td>
		</tr>
		<tr>
			<td>
				<label style="float: left; margin-right: 5px;">项目编号:</label>
				<s:textfield name="query_projectCode" theme="simple"  />
			</td>
		</tr>
		<tr>
			<td>
				<label style="float: left; margin-right: 5px;">所属公司:</label>
				<s:hidden name="query_subsidiaryId" />
				<s:textfield name="query_subsidiaryName" theme="simple" readonly="true" onclick="popUpWin('query_subsidiaryId', 'query_subsidiaryName');"  />	
			</td>
		</tr>
		<tr>
			<td>
				<label style="float: left; margin-right: 5px;">立项日期:</label>
				<s:textfield name="query_startPstartTime" theme="simple" />
				~
				<s:textfield name="query_endPstartTime" theme="simple" />
			</td>
		</tr>
		<tr>
			<td>
				<label style="float: left; margin-right: 5px;">结项日期:</label>
				<s:textfield name="query_startPendTime" theme="simple" />
				~
				<s:textfield name="query_endPendTime" theme="simple" />
			</td>
		</tr>
		<tr>
			<td style="vertical-align: top;" colspan="2">
				<a href="javascript:void(0)" id="query-project" class="easyui-linkbutton" iconCls="icon-search">查询</a>
				<a href="javascript:void(0)" id="query-reset" class="easyui-linkbutton" iconCls="icon-back">重置</a>
			</td>
		</tr>
	</table>
	</div>	
</div>

<hr/>	

<div style="width: 100%;">
	<table id="dataTable" title='项目列表'></table>
</div>
<div style="margin-top: 5px;">
	<a href="javascript:void(0)" id="create-project" class="easyui-linkbutton" iconCls="icon-add">新建</a>
	<a href="javascript:void(0)" id="modify-project" class="easyui-linkbutton" iconCls="icon-edit">修改</a>
	<a href="javascript:void(0)" id="delete-project" class="easyui-linkbutton" iconCls="icon-cancel">删除</a>
</div>

<input type="hidden" name="deleteId" id="deleteId" />


<s:include value="project_new.jsp"></s:include>
<s:include value="../include/subsidiary_popup.jsp"></s:include>

</form>
</body>
</html>